#ifndef __BOARD_H__
#define __BOARD_H__

#include <stdio.h>
#include <string.h>
#include "stm32f4xx.h"
#include "stm32f4xx_conf.h"
#include "my_math.h"

typedef u8 bool;


/**
* @struct  _vec2f
* @brief 二维float向量结构体
*/
typedef struct _vec2f
{
	float data[2];
}vec2f;

/**
* @struct  _vec2int16
* @brief 二维int16向量结构体
*/
typedef struct _vec2int16
{
	 short data[2];
}vec2int16;

/**
* @struct  _vec3f
* @brief 三维float向量结构体
*/
typedef struct _vec3f
{
	float data[3];
}vec3f;

/**
* @struct  _vec3int16
* @brief 三维int16向量结构体
*/
typedef struct _vec3int16
{
	 short data[3];
}vec3int16;

/**
* @struct  _vec4f
* @brief 四维float向量结构体
*/
typedef struct _vec4f
{
	float data[4];
}vec4f;

/**
* @struct  _vec4int16
* @brief 四维int16向量结构体
*/
typedef struct _vec4int16
{
	 short data[4];
}vec4int16;

/**
* @struct  _vec6f
* @brief 六维float向量结构体
*/
typedef struct _vec6f
{
	float data[6];
}vec6f;

/**
* @struct  _vec6int16
* @brief 六维int16向量结构体
*/
typedef struct _vec6int16
{
	 short data[6];
}vec6int16;



/***************LED GPIO定义******************/
#define  RCC_LED     RCC_AHB1Periph_GPIOA
#define  LED_PORT    GPIOA
#define  LED_Pin     GPIO_Pin_8

/***************KEY GPIO定义******************/
#define  RCC_KEY     RCC_AHB1Periph_GPIOA
#define  KEY_PORT    GPIOA
#define  KEY_Pin     GPIO_Pin_0

/***************I2C GPIO定义******************/
#define  RCC_I2C1	    RCC_AHB1Periph_GPIOB
#define  I2C1_PORT      GPIOB
#define  I2C1_Pin_SCL   GPIO_Pin_6
#define  I2C1_Pin_SDA   GPIO_Pin_7

#define  RCC_I2C2	    RCC_AHB1Periph_GPIOB
#define  I2C2_PORT      GPIOB
#define  I2C2_Pin_SCL   GPIO_Pin_10
#define  I2C2_Pin_SDA   GPIO_Pin_11

/**************SPI GPIO定义*****************/
#define  RCC_SPI1	    RCC_AHB1Periph_GPIOA
#define  SPI1_PORT      GPIOA
#define  SPI1_Pin_MOSI  GPIO_Pin_7
#define  SPI1_Pin_MISO  GPIO_Pin_6
#define  SPI1_Pin_SCK   GPIO_Pin_5

#define  RCC_SPI2	    RCC_AHB1Periph_GPIOB
#define  SPI2_PORT      GPIOB
#define  SPI2_Pin_MOSI  GPIO_Pin_15
#define  SPI2_Pin_MISO  GPIO_Pin_14
#define  SPI2_Pin_SCK   GPIO_Pin_13

#define  RCC_SPI3	    RCC_AHB1Periph_GPIOB
#define  SPI3_PORT      GPIOB
#define  SPI3_Pin_MOSI  GPIO_Pin_5
#define  SPI3_Pin_MISO  GPIO_Pin_4
#define  SPI3_Pin_SCK   GPIO_Pin_3

/**************USART GPIO定义*****************/
#define  RCC_USART1	    RCC_AHB1Periph_GPIOA
#define  USART1_PORT    GPIOA
#define  USART1_Pin_Tx  GPIO_Pin_9
#define  USART1_Pin_Rx  GPIO_Pin_10

#define  RCC_USART2	    RCC_AHB1Periph_GPIOA
#define  USART2_PORT    GPIOA
#define  USART2_Pin_Tx  GPIO_Pin_2
#define  USART2_Pin_Rx  GPIO_Pin_3

#define  RCC_USART3	    RCC_AHB1Periph_GPIOC
#define  USART3_PORT    GPIOC
#define  USART3_Pin_Tx  GPIO_Pin_10
#define  USART3_Pin_Rx  GPIO_Pin_11

void SysTick_Init(void);
uint32_t GetSysTime_us(void);
void delayUs(uint32_t us);
void delayMs(uint32_t ms);

u8 All_init(void);

extern volatile uint32_t sysTickUptime;

#endif
